#include "../include/gudb.h"
#include "../src/parser/sql_parser.h"
#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Test STATUS column parsing\n");
    printf("==========================\n\n");
    
    const char* sql = "ALTER TABLE orders MODIFY COLUMN status VARCHAR(50)";
    printf("SQL: %s\n", sql);
    
    parser_t* parser = parser_create(sql);
    if (!parser) {
        printf("Failed to create parser\n");
        return 1;
    }
    
    printf("Attempting to parse...\n");
    statement_t* stmt = parser_parse_statement(parser);
    
    if (!stmt) {
        printf("Failed to parse statement\n");
        printf("Parser error: %s\n", parser_get_error(parser) ? parser_get_error(parser) : "No error message");
        
        // Let's see where we are in parsing
        printf("Current token: type=%d, value=%s\n", 
               parser->current_token ? parser->current_token->type : -1,
               parser->current_token && parser->current_token->value ? parser->current_token->value : "NULL");
    } else {
        printf("Successfully parsed!\n");
        printf("Table name: %s\n", stmt->data.alter_table.table_name);
        printf("Column name: %s\n", stmt->data.alter_table.column_name);
        printf("Operation: %d\n", stmt->data.alter_table.operation);
        statement_destroy(stmt);
    }
    
    parser_destroy(parser);
    return 0;
}